package com.dingwei.superiordiary.adapter.easyViewHolder;

import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.app.MyApplication;
import com.dingwei.superiordiary.bean.VerietyShopBean;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.lihao.baselibrary.base.BaseActivity;
import com.lihao.baselibrary.utils.DisplayUtil;
import com.lihao.baselibrary.utils.ScreenUtils;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by lihao on 2017/9/12.
 */

public class TuijianHolder extends BaseViewHolder<VerietyShopBean.DataBean.ProductsBean> {
    @Bind(R.id.img)
    ImageView img;
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.ll)
    LinearLayout ll;

    public TuijianHolder(ViewGroup parent) {
        super(parent, R.layout.item_tuijian);
        ButterKnife.bind(this, itemView);

        LinearLayout.LayoutParams lp1 =new LinearLayout.LayoutParams((ScreenUtils.getScreenWidth(BaseActivity.context)-48)/9*5, (ScreenUtils.getScreenWidth(BaseActivity.context)-48)/9*5/5*3);
        img.setLayoutParams(lp1);
        LinearLayout.LayoutParams lp2 =new LinearLayout.LayoutParams((ScreenUtils.getScreenWidth(BaseActivity.context)-48)/9*5, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp2.setMargins(0, DisplayUtil.dip2px(BaseActivity.context,8),0,0);
        tvTitle.setLayoutParams(lp2);
    }
    @Override
    public void setData(VerietyShopBean.DataBean.ProductsBean data) {
        super.setData(data);
        tvTitle.setText(data.name);
        Glide.with(BaseActivity.context)
                .load(data.icon)
                .apply(MyApplication.options)
                .into(img);
    }
}
